package xrz.cuanbao.activity;

import java.util.ArrayList;
import java.util.List;

import org.taptwo.android.widget.ViewFlow;
import org.xutils.x;
import org.xutils.common.Callback.CommonCallback;
import org.xutils.common.util.LogUtil;
import org.xutils.image.ImageOptions;
import org.xutils.view.annotation.ViewInject;

import com.xrz.sxm.base.activity.Act_HideTop;
import com.xrz.sxm.base.utils.ScreenUtil;

import android.graphics.drawable.Drawable;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.LayoutParams;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import xrz.cuanbao.R;
import xrz.cuanbao.adapters.AllPagerAdapter;

public class Act_BigImage extends Act_HideTop implements OnPageChangeListener {

	@ViewInject(R.id.viewflow)
	private ViewFlow viewFlow;
	private List<String> paths;
	private int pos;

	private List<View> views = new ArrayList<View>();

	@Override
	protected int setContentView() {
		return R.layout.layout_bigimage;
	}

	public void onBackClick(View view) {
		finish();
	}

	@Override
	protected void initData() {
		paths = getIntent().getStringArrayListExtra("paths");
		pos = getIntent().getIntExtra("pos", 0);
		viewFlow.setAdapter(new ImageAdapterF());
	}

	@Override
	public void onPageScrollStateChanged(int arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onPageSelected(int arg0) {
		// TODO Auto-generated method stub
		pos = arg0;
	}

	private class ImageAdapterF extends BaseAdapter {

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return paths.size();
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return null;
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			if (convertView == null) {
				convertView = LayoutInflater.from(m_ctx).inflate(R.layout.image_item_bigimage, null);
			}
			// int num = 0;
			// if (position <= paths.size() - 1) {
			// num = position;
			// } else {
			// num = position % paths.size();
			// }
			x.image().bind(((ImageView) convertView.findViewById(R.id.imgView)), paths.get(position));
			return convertView;
		}

	}
}
